/*
 * Copyright(C) 2012 Luvina Software Company
 *
 * MstJapanLoginImpl.java, Jun 5, 2012 HaiPD
 */
package net.luvina.manageuser.logic.impl;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import net.luvina.manageuser.dao.MstJapanDao;
import net.luvina.manageuser.hibernate.MstJapan;
import net.luvina.manageuser.logic.MstJapanLogic;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * MstJapanLogicImpl implements MstJapanLogic
 *
 * @author HaiPD
 *
 */
@Service("japanLogic")
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false, rollbackFor = { Throwable.class })
public class MstJapanLogicImpl implements MstJapanLogic {

	@Autowired
	private MstJapanDao japanDao;

	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * net.luvina.manageuser.logic.MstJapanLogic#getListItemJapan(java.lang.
	 * String)
	 */
	@Override
	public List<SelectItem> getListItemJapan(String defaultValue) {
		List<MstJapan> listJapan = this.japanDao.getListJapan();
		SelectItem selectItemJapan;
		List<SelectItem> itemJpans = new ArrayList<SelectItem>();
		itemJpans.add(new SelectItem("", defaultValue));
		for (MstJapan japan : listJapan) {
			selectItemJapan = new SelectItem(japan.getCodeLevel(), japan
					.getNameLevel());
			itemJpans.add(selectItemJapan);
		}
		return itemJpans;
	}

}
